package com.bida.controller.admin;


import com.bida.domain.dto.SetmealDTO;
import com.bida.domain.dto.SetmealPageQueryDTO;
import com.bida.domain.vo.SetmealVO;
import com.bida.result.PageResult;
import com.bida.result.Result;
import com.bida.service.ISetmealService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 套餐 前端控制器
 * </p>
 *
 * @author ly
 * @since 2024-09-06
 */
@RestController
@RequestMapping("/admin/setmeal")
public class SetmealController {

    @Resource
    private ISetmealService setmealService;

    /**
     * 修改套餐
     *
     * @param setmealDTO
     * @return
     */
    @PutMapping
    public Result updateSetmealInfo(@RequestBody SetmealDTO setmealDTO) {
        return setmealService.updateSetmealInfo(setmealDTO);
    }

    /**
     * 分页查询 套餐
     *
     * @param setmealPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> pageGetSetmeal(SetmealPageQueryDTO setmealPageQueryDTO) {
        return setmealService.pageGetSetmeal(setmealPageQueryDTO);
    }

    /**
     * 套餐起售、停售
     *
     * @param status
     * @param id
     * @return
     */
    @PostMapping("/status/{status}")
    public Result updateSetmealStatus(@PathVariable Integer status, Long id) {
        return setmealService.updateSetmealStatus(status, id);
    }

    /**
     * 新增套餐
     *
     * @param setmealDTO
     * @return
     */
    @PostMapping
    public Result saveNewSetmeal(@RequestBody SetmealDTO setmealDTO) {
        return setmealService.saveNewSetmeal(setmealDTO);
    }

    /**
     * 根据id查询套餐
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<SetmealVO> getSetmealInfoById(@PathVariable Long id) {
        return setmealService.getSetmealInfoById(id);
    }

    /**
     * 根据id批量删除
     * @param ids
     * @return
     */
    @DeleteMapping
    public Result deleteSetmealByIds(@RequestParam List<Long> ids) {
        return setmealService.deleteSetmealByIds(ids);
    }
}